package cn.jslancer.controller;

import cn.jslancer.domain.Article;
import cn.jslancer.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jslancer
 * @date 2017/11/6
 */
@RestController("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("/list")
    public ResponseEntity<Page<Article>> findPage(Pageable pageable) {
        Page<Article> articlePage = articleService.findAll(pageable);
        return new ResponseEntity<Page<Article>>(articlePage, HttpStatus.OK);
    }

}
